<template>
    <div>
      <form action="" @submit.prevent="on_submit">
        <input type="text" v-model="username">用户名
        <button type="submit">提交</button>
      </form>
    </div>
</template>

<script>
  import axios from 'axios'
    export default {
        name: "register",
        data(){
          return{
            username:'',

          }
        },
        methods:{
          on_submit(){

            let form_data = new FormData();
            form_data.append('username',this.username);
            axios({
              url:'http://127.0.0.1:8000/register/',
              method:'POST',
              data:form_data
            }).then(res=>{
              localStorage.setItem('name',this.username);
              alert(res.data.message);
              this.$router.push('/show')
            })
          }
        }


    }
</script>

<style scoped>

</style>
